package wl.redis;


import org.apache.thrift.TMultiplexedProcessor;
import org.apache.thrift.server.TServer;
import org.apache.thrift.server.TThreadPoolServer;
import org.apache.thrift.transport.TServerSocket;
import org.apache.thrift.transport.TTransportException;

public class Server {

    //注册启动多个Service
    private static void TMstart() {
        try {
            TServerSocket serverTransport = new TServerSocket(8848);
            // 启动redis
            RedisService.Processor redisProcessor=new RedisService.Processor(
              new RedisServiceImpl()
            );


            TMultiplexedProcessor processor = new TMultiplexedProcessor();

            processor.registerProcessor("RedisService", redisProcessor);

            TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(
                    serverTransport).processor(processor));
            System.out.println("Starting server on port 8848 ...");
            server.serve();
        } catch (TTransportException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        TMstart();
    }
}
